//package com.axc.gallery2.view;
//import java.io.File;
//
//import android.app.Activity;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.os.Bundle;
//import android.util.Log;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.AdapterView;
//import android.widget.ImageButton;
//import android.widget.ImageSwitcher;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.PopupWindow;
//import android.widget.Toast;
//import android.widget.AdapterView.OnItemClickListener;
//import android.widget.AdapterView.OnItemLongClickListener;
//import android.widget.Gallery.LayoutParams;
//import android.widget.ViewSwitcher.ViewFactory;
//
//import com.axc.gallery2.R;
//import com.axc.gallery2.dbhelper.AlbumInfo;
//import com.axc.gallery2.dbhelper.ImageInfo;
//import com.axc.gallery2.edit.EditActivity;
//import com.axc.gallery2.local.SetScale;
//import com.axc.gallery2.menu.RootMenu;
//import com.axc.gallery2.net.activity.UploadPhotoActivity;
//public class CopyOfCoverFlowActivity extends Activity implements 
//ViewFactory {
//
//
//	private LinearLayout line;
//	private ImageView pImageView;
//	private PopupWindow popupWindow;
//	private View contentView;
//	private ImageAdapter imageAdapter;
//	private ImageButton imgBtnPopRevert;
//	private ImageButton imgBtnPopRew;
//	private ImageButton imgBtnPopEdit;
//	private ImageButton imgBtnPopShare;
//	private ImageButton imgBtnPopFf;
//	private ImageButton imgBtnDesktop;
//	private int index = 0;
//	private AlbumInfo albumInfo;
//	CoverFlow cf;
//
//
//
//	public View makeView() {
//		ImageView imageView = new ImageView(this);
//		imageView.setBackgroundColor(0xFF000000);
//		imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
//		imageView.setLayoutParams(new ImageSwitcher.LayoutParams(
//				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
//		return imageView;
//	}
//
//	//主题应用
//	public static CopyOfCoverFlowActivity Talbum;
//	public int theme = -1;
//
//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		// 主题
//		Talbum = this;
//		theme = getSharedPreferences("cons", MODE_PRIVATE).getInt("theme",
//				android.R.style.Theme);
//		setTheme(theme);
//		super.onCreate(savedInstanceState);
//		System.out.println("startCoverFlowActivity");
//		line = new LinearLayout(this);
//		line.setOrientation(LinearLayout.VERTICAL); 
//		RootMenu rootMenu = new RootMenu(this);
//		rootMenu.initView();
//		cf = new CoverFlow(this);
//		Bundle bundle = getIntent().getExtras();
//		albumInfo =(AlbumInfo)bundle.getSerializable(AlbumInfo.SERALIZABLEKEY);
//		imageAdapter =new ImageAdapter(this, albumInfo.getAlbumItems());
//		cf.setAdapter(imageAdapter);
//		cf.setAnimationDuration(1500);
//		cf.setOnItemLongClickListener(lonClick);
//		cf.setOnItemClickListener(new OnItemClickListener() {
//
//			@Override
//			public void onItemClick(AdapterView<?> arg0, View view, int position,
//					long arg3) {
//				// TODO Auto-generated method stub
//				showPopWindow(SampleSize.getSampleSize(imageAdapter.getList().get(position)),view);
//				index=position;
//
//			}
//		});
//		line.addView(rootMenu);
//		line.addView(cf,android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.FILL_PARENT);			
//		setContentView(line);
//		initPopWindow();
//		int position = Integer.valueOf(getIntent().getStringExtra(ImageInfo.POSITION));	
//		System.out.println("startCoverFlowActivity:"+position);
//		cf.setSelection(position);
//	}
//
//
//	public OnItemLongClickListener lonClick = new OnItemLongClickListener() {
//
//		public boolean onItemLongClick(AdapterView<?> parent, View view,
//				int position, long id) {
//
//			showPopWindow(getBitmap(position),view);
//			index=position;
//			return true;
//		}
//	};
//
//	private Bitmap getBitmap(int position) {
//		return SampleSize.getSampleSize(imageAdapter.getList().get(position));
//	}
//
//	private void initPopWindow() {  
//		// 加载popupWindow的布局文件   
//		contentView = LayoutInflater.from(getApplicationContext())  
//				.inflate(R.layout.mypopwindow, null);
//		pImageView = (ImageView) contentView.findViewById(R.id.gifView1);
//		// 声明一个弹出框   
//		popupWindow = new PopupWindow(contentView,
//				LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);  
//		popupWindow.setFocusable(true);
//		popupWindow.update(); 
//		imgBtnPopRevert = (ImageButton)contentView.findViewById(R.id.imgBtnPopRevert);
//		imgBtnPopRevert.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View arg0) {
//				popupWindow.dismiss(); 
//			}
//		});
//		imgBtnPopRew = (ImageButton)contentView.findViewById(R.id.imgBtnPopRew);
//		imgBtnPopRew.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				if(index>0&&index<imageAdapter.getCount()){
//					index--;
//					pImageView.setImageBitmap(getBitmap(index));
//					cf.setSelection(index);
//				}
//				else {
//					pImageView.setImageBitmap(getBitmap(0));
//					Toast.makeText(getBaseContext(), "第一张", Toast.LENGTH_LONG).show();
//				}
//			}
//		});
//		imgBtnPopEdit = (ImageButton)contentView.findViewById(R.id.imgBtnPopEdit);
//		imgBtnPopEdit.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				Intent intent  = new Intent();
//				intent.setClass(getBaseContext(), EditActivity.class);
//				Log.w("Path", String.valueOf(imageAdapter.getList().get(index)));
//				Bundle bundle=new Bundle();
//				bundle.putString("pp", imageAdapter.getList().get(index));
//				intent.putExtra("data", bundle);
//				CopyOfCoverFlowActivity.this.startActivity(intent);
//				popupWindow.dismiss(); 
//			}
//		});
//		imgBtnPopShare = (ImageButton)contentView.findViewById(R.id.imgBtnPopShare);
//		imgBtnPopShare.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				Intent intent  = new Intent();
//				intent.setClass(getBaseContext(), UploadPhotoActivity.class);
//				Bundle bundle=new Bundle();
//				bundle.putString(ImageInfo.IAMGEPATH, imageAdapter.getList().get(index));
//				intent.putExtra("data", bundle);
//				//intent.putExtra(Renren.RENREN_LABEL, renren);
//				intent.putExtra("file", new File(imageAdapter.getList().get(index)));
//				CopyOfCoverFlowActivity.this.startActivity(intent);
//
//			}
//		});
//		imgBtnPopFf = (ImageButton)contentView.findViewById(R.id.imgBtnPopFf);
//		imgBtnPopFf.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				if(index>=0&&index<imageAdapter.getCount()-1){
//					index++;
//					pImageView.setImageBitmap(getBitmap(index));
//					cf.setSelection(index);
//				}
//				else {
//					pImageView.setImageBitmap(getBitmap(imageAdapter.getCount()-1));
//					Toast.makeText(getBaseContext(), "最后一张", Toast.LENGTH_LONG).show();
//				}				
//			}
//		});
//		imgBtnDesktop =(ImageButton)contentView.findViewById(R.id.imgBtnPopDesktop);
//		imgBtnDesktop.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View arg0) {
//				try {
//					SetScale scale  =new SetScale(getBaseContext(),getBitmap(index),getWindowManager().getDefaultDisplay());
//					scale.start();
//					Toast.makeText(getBaseContext(), "设置成功！", Toast.LENGTH_LONG).show();
//				} catch (Exception e) {
//					Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
//				}				
//			}
//		});
//	}
//
//
//
//	private void showPopWindow(Bitmap bm,View view) {
//		pImageView.setImageBitmap(bm);
//		popupWindow.showAtLocation(view,Gravity.CENTER,0,0);
//	}
//
//
//
//}
//
